package com.es.servlet;

import com.es.OpEnum;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 描述:
 * MyBatis-
 *
 * @author Derek
 * 创建时间：2022-05-07 10:42
 */
public class BaseServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //op=save,op=update
        String op = req.getParameter("op");
        OpEnum opEnum = OpEnum.getOpEnum(Integer.parseInt(op));
        System.out.println(opEnum);
        switch (opEnum){
            case GET: get(req, resp);break;
            case SAVE: save(req,resp);break;
            case DELETE: delete(req, resp);break;
            case LIST_BY_CONDITION: listByCondition(req, resp);break;
            case LIST: list(req, resp);break;
            case UPDATE: update(req, resp);break;
            default:;
        }

    }

    protected void get(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    }
    protected void update(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }
    protected void save(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }
    protected void delete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }
    protected void list(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }
    protected void listByCondition(HttpServletRequest req, HttpServletResponse resp) {
    }
}
